package pull;

import helper.ImageData;

import javax.media.jai.JAI;

import framework.filters.AbstractPullFilter;
import framework.pipes.PullPipe;

/**
 * Reads the image from a given source (string is the path) This class extends
 * the AbstractPullFilter because we want to use a pull pipe
 * 
 * @author Wetzel & Rusch
 * 
 */
public class ImageReader extends AbstractPullFilter<ImageData> {

	private String m_image = null;
	private final ImageData m_plImage = new ImageData();

	public ImageReader(PullPipe<ImageData> pullPipe) {
		super(pullPipe);
	}

	public void setImage(String file) {
		m_image = file;
	}

	public void ReadImager() {
		m_plImage.setOriginalImage(JAI.create("fileload", m_image));
	}

	@Override
	public void doIt() {
		ReadImager();
	}

	@Override
	public ImageData pull() {
		doIt();
		return m_plImage;
	}

}
